using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Medianamik.Core.DAL.SubSonicDAL{
    /// <summary>
    /// Strongly-typed collection for the InheritedTypePermission class.
    /// </summary>
    [Serializable]
    public partial class InheritedTypePermissionCollection : ReadOnlyList<InheritedTypePermission, InheritedTypePermissionCollection>
    {        
        public InheritedTypePermissionCollection() {}
    }
    /// <summary>
    /// This is  Read-only wrapper class for the vw_medianamik_InheritedTypePermission view.
    /// </summary>
    [Serializable]
    public partial class InheritedTypePermission : ReadOnlyRecord<InheritedTypePermission>, IReadOnlyRecord
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_medianamik_InheritedTypePermission", TableType.View, DataService.GetInstance("MedianamikProvider"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarTypeId = new TableSchema.TableColumn(schema);
                colvarTypeId.ColumnName = "TypeId";
                colvarTypeId.DataType = DbType.Guid;
                colvarTypeId.MaxLength = 0;
                colvarTypeId.AutoIncrement = false;
                colvarTypeId.IsNullable = true;
                colvarTypeId.IsPrimaryKey = false;
                colvarTypeId.IsForeignKey = false;
                colvarTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarTypeId);
                
                TableSchema.TableColumn colvarGroupId = new TableSchema.TableColumn(schema);
                colvarGroupId.ColumnName = "GroupId";
                colvarGroupId.DataType = DbType.Guid;
                colvarGroupId.MaxLength = 0;
                colvarGroupId.AutoIncrement = false;
                colvarGroupId.IsNullable = false;
                colvarGroupId.IsPrimaryKey = false;
                colvarGroupId.IsForeignKey = false;
                colvarGroupId.IsReadOnly = false;
                
                schema.Columns.Add(colvarGroupId);
                
                TableSchema.TableColumn colvarInheritedFromTypeId = new TableSchema.TableColumn(schema);
                colvarInheritedFromTypeId.ColumnName = "InheritedFromTypeId";
                colvarInheritedFromTypeId.DataType = DbType.Guid;
                colvarInheritedFromTypeId.MaxLength = 0;
                colvarInheritedFromTypeId.AutoIncrement = false;
                colvarInheritedFromTypeId.IsNullable = false;
                colvarInheritedFromTypeId.IsPrimaryKey = false;
                colvarInheritedFromTypeId.IsForeignKey = false;
                colvarInheritedFromTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarInheritedFromTypeId);
                
                TableSchema.TableColumn colvarInheritedSecurityLevel = new TableSchema.TableColumn(schema);
                colvarInheritedSecurityLevel.ColumnName = "InheritedSecurityLevel";
                colvarInheritedSecurityLevel.DataType = DbType.Byte;
                colvarInheritedSecurityLevel.MaxLength = 0;
                colvarInheritedSecurityLevel.AutoIncrement = false;
                colvarInheritedSecurityLevel.IsNullable = false;
                colvarInheritedSecurityLevel.IsPrimaryKey = false;
                colvarInheritedSecurityLevel.IsForeignKey = false;
                colvarInheritedSecurityLevel.IsReadOnly = false;
                
                schema.Columns.Add(colvarInheritedSecurityLevel);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["MedianamikProvider"].AddSchema("vw_medianamik_InheritedTypePermission",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public InheritedTypePermission()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        public InheritedTypePermission(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    public InheritedTypePermission(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    public InheritedTypePermission(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("TypeId")]
        [Bindable(true)]
        public Guid? TypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid?>("TypeId");
		    }
            set 
		    {
			    SetColumnValue("TypeId", value);
            }
        }
	      
        [XmlAttribute("GroupId")]
        [Bindable(true)]
        public Guid GroupId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("GroupId");
		    }
            set 
		    {
			    SetColumnValue("GroupId", value);
            }
        }
	      
        [XmlAttribute("InheritedFromTypeId")]
        [Bindable(true)]
        public Guid InheritedFromTypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("InheritedFromTypeId");
		    }
            set 
		    {
			    SetColumnValue("InheritedFromTypeId", value);
            }
        }
	      
        [XmlAttribute("InheritedSecurityLevel")]
        [Bindable(true)]
        public byte InheritedSecurityLevel 
	    {
		    get
		    {
			    return GetColumnValue<byte>("InheritedSecurityLevel");
		    }
            set 
		    {
			    SetColumnValue("InheritedSecurityLevel", value);
            }
        }
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string TypeId = @"TypeId";
            
            public static string GroupId = @"GroupId";
            
            public static string InheritedFromTypeId = @"InheritedFromTypeId";
            
            public static string InheritedSecurityLevel = @"InheritedSecurityLevel";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
}
